<?php
defined('_JEXEC') or die;

require_once 'Mobile_Detect.php';
$detect = new Mobile_Detect;
if ( $detect->isMobile() ) {
    include('default_mobile.php');
    return;
}

$tpath	= JURI::base().'templates/'.JFactory::$application->getTemplate();
JHtml::_('behavior.keepalive');
$sess=JFactory::getSession();

	$fornavn='';	$efternavn='';
	$alder='';	$hojde='';
	$vagt='';	$weekdown='';
	$weightdown='';	$mobile='';
	$sky='';	$email='';
	$civilstatus='';	$choicemaker='';
	$kidage=array('','','','');	$hvorkg=array('','','','');;
if($dat=$sess->get("regs1.data")){
	extract($dat);//all keys become variables
	$kidage=explode(',',$kidage);
	$kidage=array_pad($kidage, 4, "");
	
	$hvorkg=explode(',',$hvorkg);
	$hvorkg=array_pad($hvorkg, 4, "");
}
?>
<style type="text/css">
	.info form input.invalid{
		background-color: #fdd;
	}
</style>
<script type="text/javascript">
function isValidEmail(str) {

	var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);

	return pattern.test(str);

	}
function check()
{
	var tmp=jQuery("#fornave");
	var flg=1;
	if(tmp.val()==''){
			 tmp.addClass('invalid');
			flg=0;
	}
	else
		tmp.removeClass('invalid');
	
	tmp=jQuery("#efternavn");
	if(tmp.val()=='')
	{
			 tmp.addClass('invalid');
			 flg=0;
	}
	else
		tmp.removeClass('invalid');
	
	tmp=jQuery("#alder");
	if(tmp.val()=='')
	{
			 tmp.addClass('invalid');
			 flg=0;
	}
	else
		tmp.removeClass('invalid');
	
	tmp=jQuery("#hojde");
	if(tmp.val()=='')
	{
			 tmp.addClass('invalid');
			 flg=0;
	}
	else
		tmp.removeClass('invalid');
	
	tmp=jQuery("#vagt");
	if(tmp.val()=='')
	{
			 tmp.addClass('invalid');
			 flg=0;
	}
	else
		tmp.removeClass('invalid');
	
	tmp=jQuery("#mobile");
	if(tmp.val()=='')
	{
			 tmp.addClass('invalid');
			 flg=0;
	}
	else
		tmp.removeClass('invalid');
	
	
	tmp=jQuery("#email");
	if(!isValidEmail(tmp.val()))
	{
			 tmp.addClass('invalid');
			 flg=0;
	}
	else
		tmp.removeClass('invalid');
	
	tmp=jQuery("#reemail");
	if( !isValidEmail(tmp.val()) || tmp.val() != jQuery("#email").val() )
	{
			 tmp.addClass('invalid');
			 flg=0;
	}
	else
		tmp.removeClass('invalid');
	
	tmp=jQuery("#password");
	if(tmp.val()=='')
	{
			 tmp.addClass('invalid');
			 flg=0;
	}
	else
		tmp.removeClass('invalid');
	
	tmp=jQuery("#repassword");
	if( tmp.val()=='' || tmp.val() != jQuery("#password").val() )
	{
			 tmp.addClass('invalid');
			 flg=0;
	}
	else
		tmp.removeClass('invalid');
	
	if(flg)
		return true;
	return false;
}
function formvalidate(){
	if(check())
		jQuery('#member-registration').submit();
	return false;
}
</script>
<style type="text/css">
	.nohand{cursor:default}
</style>
<div class="wrapper">
	<div class="content" id="createAccount-page">
		<div class="col-wrapper clearfix">
			<div class="info">
				<ul class="breadcrumb mb20">
					<li class="active"><a>Personlige oplysninger</a></li>
					<li><a class="nohand">Dit abonnement</a></li>
					<li><a class="nohand">Book tid hos din vejleder</a></li>
					<li><a class="nohand">Kostvaner/ ønsker</a></li>
					<li><a class="nohand">Motionsvaner/ ønsker</a></li>
					
				</ul>
				<form id="member-registration" method="post" class="form-validate">
					<h1 class="hd">Personlige oplysninger</h1>
					<div class="info-l mh460 bor">
						<div>
							<p>Alle felter markeret med *rød stjerne skal besvares – resten er valgfrie. Men vi opfordrer til at udfylde flest mulige felter, da det giver vejlederen mest mulig information inden jeres webmøde.</p>
							<p>Har du nogle spørgsmål eller andet undervejs, er du meget velkommen til at kontakt kundeservice <a href="index.php?option=com_contact&view=contact&id=1" style="text-decoration: underline" target="_blank">her</a></p>
						</div>
			<div>
				<label>Fornavn <span>*</span></label>
				<input name="jform[fornavn]" id="fornave" value="<?php echo $fornavn?>" required>
			</div>
			<div class="ml15">
				<label>Efternavn <span>*</span></label>
				<input name="jform[efternavn]" id="efternavn" value="<?php echo $efternavn?>" required>
			</div>
			<div>
				<label class="mt15">Alder <span>*</span></label>
				<input class="w77" name="jform[alder]" id="alder" value="<?php echo $alder ?: ""?>" required>
			</div>
			<div class="ml10">
				<label class="mt15">Højde <span>*</span></label>
				<input class="w77" name="jform[hojde]" id="hojde" value="<?php echo $hojde ?: ""?>" required>
			</div>
			<div class="ml10">
				<label class="mt15">Vægt <span>*</span></label>
				<input class="w77" name="jform[vagt]" id="vagt" value="<?php echo $vagt ?:""?>" required>
			</div>
						<div class="ml10">
							<label style="margin-top: -3px;" class="mt17">Ønsker du vægttab<br>eller muskelforøgelse?</label>
							<select class="w138" name="jform[weekdown]" id="mangeuger">
								<option value="1" <?php if($weekdown==1) echo "selected"?>>Vægttab</option>
								<option value="2" <?php if($weekdown==2) echo "selected"?>>Muskelforøgelse</option>
								
							</select>
						</div>
						<div class="ml15">
							<label style="margin-top: 16px;" class="w126">Hvor mange kg.?</label>
							<input class="w126" name="jform[weightdown]" id="duattabe" value="<?php echo $weightdown ;?>">
						</div>
						
			<div>
				<label>Mobiltelefon <span>*</span></label>
				<input name="jform[mobile]" id="mobile" value="<?php echo $mobile?>" required>
			</div>
						<div class="ml15">
							<div class="w275 fl mb0">
							<label class="fl">Skype id </label>
							<div class="fl skypeid"><img src="<?php echo $tpath; ?>/img/imgInfo.png" alt="">
								<span class="tip">Skype bruges til de webmøder der afholdes mellem dig og din nye kost- og træningsvejleder<br><br>
								Hvis du ikke har en Skype konto i forvejen, bedes du oprette en <a target="blank" href="https://login.skype.com/account/signup-form?return_url=https%3A%2F%2Fsecure.skype.com%2Faccount%2Flogin">her</a><br><br>
								Skype kan også bruges via din smartphone -hent Skype app'en <a target="blank" href="https://itunes.apple.com/en/app/skype-for-iphone/id304878510?mt=8">her</a><br><br>
								Har du problemer, så kontakt venligst vores support team <a target="blank" href="index.php?option=com_contact&view=contact&id=1">her</a>
								<span class="arr-left"></span></span>
							</div>
							</div>
							<div class="clear mb0"></div>
							<div class="fl">
							<input name="jform[sky]" id="sky" value="<?php echo $sky?>" >
							</div>
						</div>
			<div>
				<label>E-mail <span>*</span></label>
				<input name="jform[email]" id="email" value="<?php echo $email?>" required>
			</div>
			<div class="ml15">
				<label> Gentag e-mail <span>*</span></label>
				<input name="reemail" id="reemail" value="<?php echo $email?>" required>
			</div>
			<div>
				<label>Kodeord <span>*</span></label>
				<input type="password" name="jform[password]" id="password" required>
			</div>
			<div class="ml15">
				<label>Gentag kodeord <span>*</span></label>
				<input type="password" name="repassword" id="repassword" required>
			</div>

					</div>

					<div class="info-r mh460 bor infor-nam">
						<div>
							<label>Din civilstatus:</label>
							<input <?php if(!$civilstatus) echo "checked" ?> class="ra" type="radio" name="jform[civilstatus]" value=""> Single<br class="mb5 mt10">
							<input <?php if($civilstatus) echo "checked" ?> class="ra" type="radio" name="jform[civilstatus]" value="1"> Samlevende?
						</div>
						<div>
							<label>Har du hjemmeboende børn?</label>
						</div>
						<div>
							<label class="fl">Hvis ja, hvor mange og<br> hvillken alder? </label>
							<select class="w115 ml15" id="choicemaker" name="jform[choicemaker]">
								<option value="">Nej</option>
							<?php $i=0;
							while(++$i<5){
								echo '<option value="',$i,'"',($choicemaker==$i ? " selected" : ''),'>',$i,'</option>';
							}?>
							</select>
						</div>
						<div id="w-privat">
							<div id="nam1" <?php if(!$choicemaker) echo 'class="hide"'?>>
								<label>Alder på 1. barn (år)</label>
								<input class="w111" name="jform[kidage][0]" id="text_nam_1" value="<?php echo $kidage[0]?>">
							</div>
							 <div class="ml10<?php if((int)$choicemaker==1 || !$choicemaker) echo ' hide' ?>" id="nam2">
								<label>Alder på 2. barn (år) </label>
								<input class="w111" name="jform[kidage][1]" id="text_nam_2" value="<?php echo $kidage[1]?>">
							</div>
							 <div id="nam3" <?php if((int)$choicemaker<3 || !$choicemaker) echo 'class="hide"'?>>
								<label>Alder på 3. barn (år) </label>
								<input class="w111" name="jform[kidage][2]" id="text_nam_3" value="<?php echo $kidage[2]?>">
							</div>
							 <div class="ml10<?php if((int)$choicemaker<4 || !$choicemaker) echo ' hide' ?>" id="nam4">
								<label>Alder på 4. barn (år) </label>
								<input class="w111" name="jform[kidage][3]" id="text_nam_4" value="<?php echo $kidage[3]?>">
							</div>
						</div>
						<div>
							<label>Delmål:</label>
							<p class="mt10">Hvor mange kg. ønsker du at tabe?</p>
						</div>
						<div>
							<label>1. måned (Kg) </label>
							<input class="w111" name="jform[hvorkg][0]" id="hvorkg1" value="<?php echo $hvorkg[0]?>">
						</div>
						 <div class="ml10">
							<label>2. måned (Kg) </label>
							<input class="w111" name="jform[hvorkg][1]" id="hvorkg2" value="<?php echo $hvorkg[1]?>">
						</div>
						 <div>
							<label>3. måned (Kg) </label>
							<input class="w111" name="jform[hvorkg][2]" id="hvorkg3" value="<?php echo $hvorkg[2]?>">
						</div>
						 <div class="ml10">
							<label>4. måned (Kg)</label>
							<input class="w111" name="jform[hvorkg][3]" id="hvorkg4" value="<?php echo $hvorkg[3]?>">
						</div>
					</div>
					<div class="clear"></div>
					<a class="fr bntNext" onclick="return formvalidate();">Næste</a>
					<input type="hidden" name="option" value="com_users"/>
					<input type="hidden" name="task" value="registration.step1"/>
					<?php echo JHtml::_('form.token');?>
				</form>
			</div>
		</div>
	</div>
</div>